Name :Subtract Count

Symbol :CTD

Illustrate:

    You can use the Subtract Count command to decrement the value of the output CV. If the signal status of the input CD changes from "0" to "1" (the rising edge of the signal), the command is executed while the current counter value of the CV is output minus 1. Each time a rising edge of a signal is detected, the counter value is decremented by 1 until the lower limit of the specified data type is reached. When the lower limit is reached, the signal status of the input CD will no longer affect the instruction.
    You can query the counter status in the Q output. If the current counter value is less than or equal to "0", the signal status of the Q output will be set to "1". In all other cases, the signal status of the output Q is "0".
    When the signal status of input LD1 changes to "1", the value of the output CV is set to the value of the parameter PV. As long as the signal status of the input LD1 remains "1", the signal status of the input CD will not affect the instruction.

Image:

Parameter:

Parameter Statement Type Description
CD Input BOOL
Count input
LD1 Input BOOL
Reset input
PV Input INT
Set the output value of Q
Q Output BOOL
Counter status
CV Output INT
The current counter value

Example:

LD:

ST:



Interpretation:

    When the signal status of the "TagIn1" operand changes from "0" to "1", the command is executed and the value of the output of "TagCV" is reduced by 1. Each time a rising edge of the signal is detected, the counter value is decremented by 1 until the lower limit of the specified data type (INT=-32768) is reached.
    As long as the current counter value is less than or equal to 0, the signal status of the "TagOut" output is "1". In all other cases, the signal status of the output "TagOut" is "0".